package com.easwift.qsp.das.dvw16;
import java.io.BufferedOutputStream;
/**
 * dvw16写数据线程
 * @author Administrator
 *
 */
public class DVWSocketWriteThread extends Thread{
	
	private BufferedOutputStream bos;

	public DVWSocketWriteThread(BufferedOutputStream bos) {
		super();
		this.bos = bos;
	}
	
	@Override
	public void run(){
		try{
			while(true){
				//TODO 地址两位看看应该怎么取到发送
				//读取仪器地址
//				byte[] bytes = {0x00,0x00,(byte)0xd7,(byte)0xef,0x02,0x00,0x14,0x00,0x00,0x00,0x02,0x00,(byte)0xf8,(byte)0xd3};
				//写入仪器地址
//				byte[] bytes = {0x00,0x00,(byte)0xd7,(byte)0xef,0x04,0x00,0x14,0x00,0x00,0x00,0x02,0x00,(byte)0xf8,(byte)0xd3,0x06,0x04,(byte)0xf8,(byte)0xd3};
				//读取仪器电压
//				byte[] bytes = {0x00,0x00,(byte)0xd7,(byte)0xef,0x02,0x00,0x04,0x00,0x00,0x00,0x04,0x00,(byte)0xf8,(byte)0xd3};
				//写入仪器电压
//				byte[] bytes = {0x00,0x00,(byte)0xd7,(byte)0xef,0x04,0x00,0x04,0x00,0x00,0x00,0x04,0x00,(byte)0xf8,(byte)0xd3,(byte)0xff,(byte)0xff,0x00,0x00,(byte)0xf8,(byte)0xd3};
				//读取仪器频率
//				byte[] bytes = {0x00,0x00,(byte)0xd7,(byte)0xef,0x02,0x00,0x28,0x00,0x00,0x00,0x04,0x00,(byte)0xf8,(byte)0xd3};
				//写入仪器频率
//				byte[] bytes = {0x00,0x00,(byte)0xd7,(byte)0xef,0x04,0x00,0x28,0x00,0x00,0x00,0x04,0x00,(byte)0xf8,(byte)0xd3,(byte)0xff,(byte)0xff,0x00,0x00,(byte)0xf8,(byte)0xd3};
				//读取仪器频率+电阻
				byte[] bytes = {0x00,0x00,(byte)0xd7,(byte)0xef,0x02,0x00,0x00,0x03,0x00,0x00,(byte)0x80,0x00,(byte)0xf8,(byte)0xd3};
				bos.write(bytes);
				bos.flush();
				//TODO 读取数据的频率从平台中读取
				Thread.sleep(6000);
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
}